package com.guage.service.impl;

import com.guage.model.ShopGoods;
import com.guage.mapper.ShopGoodsMapper;
import com.guage.service.IShopGoodsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.guage.commons.result.PageInfo;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author dechao.yang
 * @since 2017-12-14
 */
@Service
public class ShopGoodsServiceImpl extends ServiceImpl<ShopGoodsMapper, ShopGoods> implements IShopGoodsService {

     @Autowired
     private ShopGoodsMapper shopGoodsMapper;
	
	@Override
	public void selectDataGrid(PageInfo pageInfo) {        
        Page<ShopGoods> page = new Page<ShopGoods>(pageInfo.getNowpage(), pageInfo.getSize());        
        EntityWrapper<ShopGoods> wrapper = new EntityWrapper<ShopGoods>();
        wrapper.orderBy(pageInfo.getSort(), pageInfo.getOrder().equalsIgnoreCase("ASC"));
        selectPage(page, wrapper);        
        pageInfo.setRows(page.getRecords());
        pageInfo.setTotal(page.getTotal());
	}

	@Override
	public void insertByVo(ShopGoods shopGoodsVo) {
		shopGoodsMapper.insert(shopGoodsVo);
	}
}
